package com.ysd.service.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.service.dao.WeatherDao;
import com.ysd.service.entity.Weather;
import com.ysd.service.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WeatherService extends ServiceImpl<WeatherDao, Weather> {

    @Autowired
    private WeatherDao weatherDao;

    /**
     * 清空表数据
     */
    public void deleteWeatherTemp(){
        weatherDao.deleteWeatherTemp();
    }

    /**
     * 详情
     */
    public Weather queryInfoByDateCity(String date, String city){
        LambdaQueryWrapper<Weather> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(Weather::getLocationName, city);
        queryWrapper.eq(Weather::getWeatherDate, DateUtil.getYmd());
        return weatherDao.selectOne(queryWrapper);
    }

}
